﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TuringVM.Core;

namespace TuringVM.Esoteric
{
    public class EsotericCompiler: CompilerBase
    {
        private CommandSet _commands = Esoteric.GetDefaultCommandSet();

        public override byte[] Compile(string source)
        {
            var lines = source.Split('\n').
                Select(line => line.Trim()).
                Where(line => line != String.Empty);

            var bytes = new List<byte>();

            foreach (string commandName in lines)
            {
                bytes.Add(_commands[commandName].Code);
            }

            return bytes.ToArray();
        }
    }
}
